package zzz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import zzz.mapper.UserMapper;
import zzz.model.User;
import zzz.service.UserService;

@Service
@Transactional  //�˴����ٽ��д���SqlSession���ύ���񣬶��ѽ���springȥ�����ˡ�
public class UserServiceImpl implements UserService{

	@Autowired
	private UserMapper mapper;
	
	public User login(User user) {
		// TODO Auto-generated method stub
		User users=mapper.checkUser(user);
		return users;
	}

	@Override
	public boolean regUser(User user) {
		// TODO Auto-generated method stub
		if(mapper.regUser(user)==1){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public List<User> getAllUser() {
		// TODO Auto-generated method stub
		List<User> allUsers=mapper.getAllUser();
		return allUsers;
	}

	@Override
	public void deleteUser(String id) {
		// TODO Auto-generated method stub
		mapper.deleteUser(id);
		System.out.println(id);
	}

	@Override
	public int addUser(User user) {
		// TODO Auto-generated method stub
		int i=mapper.addUser(user);
		return i;
	}

	@Override
	public User findUserById(String userId) {
		// TODO Auto-generated method stub
		User user=mapper.getUserById(userId);
		return user;
	}

	@Override
	public int updateUser(User user) {
		// TODO Auto-generated method stub
		int i=mapper.updateUser(user);
		return i;
	}
	

}
